import * as bootstrap from "bootstrap"
export const  showErrMsg = (message:string) :void => {
    const toastLiveExample = document.getElementById('errorAlert')
    // const toastLiveExample = document.getElementById(PublicComponent.errorAlert)
    if (toastLiveExample) {
        const smallElement = toastLiveExample.querySelector('.toast-header small');
        
        if (smallElement) {
          smallElement.textContent = "错误：" + message;
        }
        const toast = bootstrap.Toast.getOrCreateInstance(toastLiveExample);
    toast.show();
    }
}

export const  showMsg = (message:string) :void => {
    const toastLiveExample = document.getElementById('errorAlert')
    // const toastLiveExample = document.getElementById(PublicComponent.errorAlert)
    if (toastLiveExample) {
        const smallElement = toastLiveExample.querySelector('.toast-header small');
        
        if (smallElement) {
          smallElement.textContent =  message;
        }
        const toast = bootstrap.Toast.getOrCreateInstance(toastLiveExample,{delay:2000});

    toast.show();
    }
}

export const showSaveMsg = ():void =>{
    const toastLiveExample = document.getElementById('liveToast')
    if (toastLiveExample) {
        const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample, { animation: true, autohide: true, delay: 700 })
        toastBootstrap.show()
    }
}